﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DLL;
using Public;

namespace QLBanVe
{
    public partial class ucHuyDatCho : UserControl
    {
        public ucHuyDatCho()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void txtMaKhachHang_TextChanged(object sender, EventArgs e)
        {
            KhachHangDLL khdll = new KhachHangDLL();
            KhachHangPublic khp = new KhachHangPublic();
            khp.MaKhachHang = txtMaKhachHang.Text;
            DataTable dt = khdll.Timkiem(khp);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {

                    txtTenHanhKhach.Text = dr["TenKhachHang"].ToString();
                    txtDienThoai.Text = dr["DienThoai"].ToString();
                    txtCMND.Text = dr["CMND"].ToString();
                    txtDienThoai.Text = dr["DienThoai"].ToString();
                    

                }
            }

            else
            {
               
                txtTenHanhKhach.Text = "";
                txtCMND.Text = "";
                txtDienThoai.Text = "";
            }
        }

        private void btnHuyPhieu_Click(object sender, EventArgs e)
        {
            PhieuDatChoPublic p = new PhieuDatChoPublic();
            PhieuDatChoDLL d = new PhieuDatChoDLL();
            p.MaChuyenBay = txtMaChuyenBay.Text;
            int i = d.XoaPhieuDat(p);
            if (i > 0) MessageBox.Show("Thành công");
            else
                MessageBox.Show("Thất bại");
        }

        private void ucHuyDatCho_Load(object sender, EventArgs e)
        {
            txtCMND.Enabled = false;
            txtTenHanhKhach.Enabled = false;
            txtDienThoai.Enabled = false;
        }
    }
}
